<?php
   
   class Info extends Admin{
   	   
	   public function __construct(){
		parent::__construct();
	   }
	   
	   public function setPlugIn(){
			return array("page.php");
	   }
	   
	   public function Index(){
	   	$this->mod  = "Index";
		$categoryid = intval($_GET['categoryid']);
		if($categoryid){
			$category  = DB::fetch_row("select *from `bb_category_info` where `categoryid`='{$categoryid}'");
			$this->_T['category'] =  $category;
		}		
		$sql = "select *from `bb_info` as I left join `bb_info_info` as II on I.`infoid`=II.`infoid` where I.`deleted`='0' ";
		$sql.= $categoryid?" and I.`categoryid`='{$categoryid}'":"";
		$sql.= " order by I.`infoid` desc ";
		$page  = new Page(20,$sql);
		$infos = $page->content;
		foreach($infos as $key=>$val){
			$infos[$key]['newsdate'] = date("Y-m-d",$val['newstime']);
		}
		$this->_T['infos']   = $infos;
		$this->_T['infoNum']  = $page->num;
		$this->_T['pageOne']  = $page->first_page;
		$this->_T['pageLast'] = $page->last_page;
		$this->_T['pageVal']  = $page->pageval;
		$this->_T['pagePre']  = $page->pageval-1;
		$this->_T['pageNext'] = $page->pageval+1;
		$this->template("parent");
	   }
	   
	   public function Cycle(){
	   	$this->mod  = "Cycle";
		$categoryid = intval($_GET['categoryid']);
		if($categoryid){
			$category  = DB::fetch_row("select *from `bb_category_info` where `categoryid`='{$categoryid}'");
			$this->_T['category'] =  $category;
		}		
		$sql = "select *from `bb_info` as I left join `bb_info_info` as II on I.`infoid`=II.`infoid` where I.`deleted`='1' ";
		$sql.= $categoryid?" and I.`categoryid`='{$categoryid}'":"";
		$sql.= " order by I.`infoid` desc ";
		$page  = new Page(20,$sql);
		$infos = $page->content;
		foreach($infos as $key=>$val){
			$infos[$key]['newsdate'] = date("Y-m-d",$val['newstime']);
		}
		$this->_T['infos']   = $infos;
		$this->_T['infoNum']  = $page->num;
		$this->_T['pageOne']  = $page->first_page;
		$this->_T['pageLast'] = $page->last_page;
		$this->_T['pageVal']  = $page->pageval-1;
		$this->_T['pagePre']  = $page->pageval-1;
		$this->_T['pageNext'] = $page->pageval+1;
		$this->template("parent");
	   }
	   
	   public function Delete(){
	   	
	   }
	   
	   /*
	    * 重写template函数
	    */
	   protected function template($common){
	   	if($common=="parent"){
	   		$this->_T['css']   = "APP/view/Admin/css/";
			$this->_T['image'] = "APP/view/Admin/images/";
			$this->_T['js']    = "APP/view/Admin/js/";
		}else{
			$this->_T['css']   = $this->template_dir."css/";
			$this->_T['image'] = $this->template_dir."images/";
			$this->_T['js']    = $this->template_dir."js/";
		}
		$this->smarty->assign("T",$this->_T);
		$this->smarty->display("APP/view/Admin/Header.html");
		$this->smarty->display($this->template_dir.$this->mod.".html");
		$this->smarty->display("APP/view/Admin/Footer.html");
	   }
   }
 
 

?>